package com.starview.star.compiler.canonical;

import com.starview.platform.data.type.Location;
import com.starview.platform.data.type.StandardTypes;
import com.starview.star.compiler.standard.StandardNames;
import com.starview.star.compiler.util.PrettyPrintDisplay;

@SuppressWarnings("serial")
public class Yield extends Action
{
  private final IContentAction yielded;

  public Yield(Location loc, IContentAction yielded)
  {
    super(loc, StandardTypes.unitType);
    this.yielded = yielded;
  }

  public IContentAction getYielded()
  {
    return yielded;
  }

  @Override
  public void accept(ActionVisitor visitor)
  {
    visitor.visitYield(this);
  }

  @Override
  public void prettyPrint(PrettyPrintDisplay disp)
  {
    disp.appendWord(StandardNames.IGNORE);
    yielded.prettyPrint(disp);
  }

  @Override
  public void accept(CanonicalVisitor visitor)
  {
    visitor.visitYield(this);
  }

  @Override
  public <A, E, P, C, D, T> A transform(TransformAction<A, E, P, C, D, T> transform, T context)
  {
    return transform.transformYield(this, context);
  }

}
